var t = getApp();

Page({
    data: {
        start1: !1,
        imgcode: "",
        country_code: "",
        from: {
            code: "",
            country: "86",
            mobile: "",
            mobileErr: "",
            password: "",
            passwordErr: "",
            confirm_password: "",
            confirm_passwordErr: "",
            captcha: ""
        },
        codetext: "获取短信验证码",
        visibleSet: !1,
        visibleSure: !1
    },
    onLoad: function(t) {
        this.getimgdata();
    },
    getyzm: function() {
        if (console.log("获取验证码"), this.data.start1) return !1;
        var t = 60, e = this;
        e.setData({
            start1: !0,
            codetext: "(" + t + ")秒后重新获取"
        });
        var o = setInterval(function() {
            e.setData({
                codetext: "(" + --t + ")秒后重新获取"
            });
        }, 1e3);
        setTimeout(function() {
            e.setData({
                codetext: "获取短信验证码",
                start1: !1
            }), clearInterval(o);
        }, 6e4), e.verificationCode(o);
    },
    verificationCode: function(e) {
        var o = this;
        if (t._isTextEmpty(this.data.from.mobile)) return wx.showToast({
            icon: "none",
            title: "请填写手机号",
            duration: 1500
        }), o.setData({
            codetext: "获取短信验证码",
            start1: !1
        }), void clearInterval(e);
        if ("86" == this.data.from.country && t._isMoblie(this.data.from.mobile)) wx.showToast({
            icon: "none",
            title: "请填写正确的手机号",
            duration: 1500
        }); else {
            if (t._isTextEmpty(this.data.from.captcha) && this.data.imgcode) return wx.showToast({
                icon: "none",
                title: "请填图形验证码",
                duration: 1500
            }), o.setData({
                codetext: "获取短信验证码",
                start1: !1
            }), void clearInterval(e);
            var a = t.getNetAddresss("member.register.sendCodeV2");
            a += "&mobile=" + this.data.from.mobile, a += "&state=" + this.data.from.country, 
            a += "&captcha=" + this.data.from.captcha, a += "&code=" + this.data.from.code, 
            a += "&reset=1", a += "&sms_type=2", t._getNetWork({
                url: a,
                validateBol: 2,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? wx.showToast({
                        icon: "none",
                        title: "已发送",
                        duration: 1500
                    }) : (wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    }), o.setData({
                        "from.captcha": ""
                    }), o.getimgdata());
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    value_one: function(t) {
        console.log(t.detail.value), this.setData({
            "from.mobile": t.detail.value
        }), console.log(this.data.from);
    },
    value_two: function(t) {
        "img" == t.currentTarget.dataset.key ? this.setData({
            "from.captcha": t.detail.value
        }) : this.setData({
            "from.code": t.detail.value
        });
    },
    value_thr: function(t) {
        this.setData({
            "from.password": t.detail.value
        }), console.log(this.data.from.password);
    },
    value_four: function(t) {
        this.setData({
            "from.confirm_password": t.detail.value
        });
    },
    confirm: function() {
        if (t._isTextEmpty(this.data.from.mobile)) wx.showToast({
            title: "请填写手机号",
            icon: "none",
            duration: 1e3
        }); else if (t._isMoblie(this.data.from.mobile) && "86" == this.data.from.country) wx.showToast({
            title: "请填写正确的手机号",
            icon: "none",
            duration: 1e3
        }); else if (t._isTextEmpty(this.data.from.code)) wx.showToast({
            title: "请填验证码",
            icon: "none",
            duration: 1e3
        }); else if (t._isTextEmpty(this.data.from.password)) wx.showToast({
            title: "请填写密码",
            icon: "none",
            duration: 1e3
        }); else if (t._isTextEmpty(this.data.from.confirm_password)) wx.showToast({
            title: "请填写确认密码",
            icon: "none",
            duration: 1e3
        }); else if (this.data.from.password == this.data.from.confirm_password) if (this.data.imgcode && t._isTextEmpty(this.data.from.captcha)) wx.showToast({
            title: "图形验证码不能为空",
            icon: "none",
            duration: 1e3
        }); else {
            var e = t.getNetAddresss("member.register.changePassword"), o = this.data.from;
            t._postNetWork({
                url: e,
                data: o,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? wx.showToast({
                        title: "修改成功",
                        icon: "none",
                        duration: 1e3,
                        success: function() {}
                    }) : wx.showToast({
                        title: e.msg,
                        icon: "none",
                        duration: 1e3
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else wx.showToast({
            title: "两次密码不一致",
            icon: "none",
            duration: 1e3
        });
    },
    getimgdata: function() {
        var e = this, o = t.getNetAddresss("home-page.getCaptcha");
        t._getNetWork({
            url: o,
            validateBol: 2,
            success: function(t) {
                var o = t.data;
                1 == o.result && o.data.captcha && e.setData({
                    imgcode: o.data.captcha.img
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getCountryCode: function() {
        var e = this, o = t.getNetAddresss("member.register.getInviteCode");
        t._getNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                1 == o.result && e.setData({
                    country_code: o.data.country_code
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    SetPwdClick: function() {
        this.setData({
            visibleSet: !this.data.visibleSet
        });
    },
    surePwdClick: function() {
        this.setData({
            visibleSure: !this.data.visibleSure
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});